HAL FMAC migration: List of applicable concepts

This section provides information about the HAL FMAC applicable architecture concepts.

Concepts for FMAC

Concept

Description

Separation of initialization and configuration functions

The initialization has been split into separate initialization and configfiguration functions:

  • HAL_FMAC_Init(): initializes the handle and links it to a FMAC instance.

  • HAL_FMAC_SetConfig(): sets the basic configuration to enable the use of the FMAC instance.

Removal and conversion of init structure to configuration structure

The initialization structure FMAC_InitTypeDef has been removed from the handle.

Renaming of the handle structure

The handle structure has been renamed to hal_fmac_handle_t.

Remove MspInit and MspDeInit callbacks

HAL_FMAC_MspInit and HAL_FMAC_MspDeInit are no longer available and have been replaced by a user sequence to initialize and configure the FMAC.

Unitary configuration APIs

New APIs are available to get and set FMAC features.

Dedicated DMA link APIs replace generic __HAL_LINKDMA macro

The __HAL_LINKDMA macro is no longer provided and new functions HAL_FMAC_SetWriteX1DMA() and HAL_FMAC_SetReadYDMA() are provided to link a FMAC HAL handle to a DMA HAL handle.

Introduction of HAL user data set/get APIs

Two functions to set/get user data are available: HAL_FMAC_SetUserData() and HAL_FMAC_GetUserData().

Individual callback registration APIs replace global register and unregister functions

The callback registration is handled by specific functions for each FMAC event. These functions are used to register callback functions for different FMAC events.

Introduce specialized IRQ handlers

HAL_FMAC_IRQHandler remains available as the global interrupt handler. In addition, the new HAL_FMAC_ERROR_IRQHandler is provided; it is intended to be used instead of HAL_FMAC_IRQHandler when neither HAL_FMAC_WriteX1_IT nor HAL_FMAC_ReadY_IT processes are used.

Removal of hardware-related macros in HAL2

All hardware macros have been removed from the HAL FMAC driver, and equivalent services are ensured through the LL APIs.

Revised and optimized HAL state machine

The FMAC state machine is reworked to ensure transitions of the peripheral functional states.

Revised and optimized HAL API status returns

The HAL FMAC functions were updated to return:

  • HAL_INVALID_PARAM: in case of a NULL p_config structure pointer.

  • HAL_ERROR: in case of an error.

  • HAL_TIMEOUT: in case of a user timeout.

  • HAL_BUSY: in case of an ongoing process.

  • HAL_OK: in case of a successfully completed operation.

Revised and optimized HAL error management

Involves redesigning the error handling mechanisms within the HAL to improve the detection, reporting, and handling of errors.

New APIs for filtering optional asynchronous process interrupts

New HAL FMAC Write and Read data APIs with interrupt filtering capability, such as HAL_FMAC_WriteX1_DMA_Opt() and HAL_FMAC_ReadY_DMA_Opt().

Replaced TypeDef suffix with _t in type names

All TypeDef parts of the HAL FMAC driver have been removed and replaced by _t.

Replaced nonmodifiable pointers with const keywords

Const keywords have been added to non-modifiable pointers to ensure that either the pointer itself or the data it points to cannot be modified. This enhances code safety and readability, prevents unintended modifications, and renders code more robust and maintainable.

Assertion implementation and usage in HAL1

The parameters and state are checked using ASSERT_DBG_STATE and ASSERT_DBG_PARAM macro macros.

Replace Finite Parameter Defines (Including PPP Instances) with Enum Types at HAL Levels.

Finite parameters (including FMAC instances) have been converted into enumerated types (enums) at HAL level. This improves code readability, maintainability, and type safety.

Optimize HAL PPP IRQ Handlers by Reordering Processes and Error Management Statements to Prioritize Critical Interrupts

In HAL2, the implementation of HAL_FMAC_IRQHandler API has been improved to prioritize the handling of critical interrupts.

Add HAL_PPP Prefix to All HAL Peripheral APIs (Defines, Macros, Types, and Functions).

All HAL FMAC functions start with HAL_FMAC. All HAL FMAC enumerations and structures start with hal_fmac.

Other HAL FMAC changes

Concept

Consideration

Mix DMA / IT / Polling in the same functions.

  • In HAL1, input and output modes are configured via the HAL_FMAC_FilterConfig() function.

  • In HAL2, input and output data management is handled by dedicated HAL mechanisms.

Rework the configuration and processing APIs:

  • Main process config : buffer X1, X2 and Y @ size and watermark : only mandatory param

  • Main process action (preload polling/IT/DMA, start filter FIR, IIR) A method for each action with relevant parameter only

  • Sub process action for X1 FIFO buffer Write method polling/IT/DMA

  • Sub process action for Y1 FIFO buffer Read method polling/IT/DMA